import React from 'react'
import { User } from '../SearchProject';

interface Project{
  id:number,
  name:string,
  personId:number,
  organization:string,
  created:number
}
export interface ListType{
  projects:Project[]
  users:User[]
}

export default function List({projects,users}:ListType) {
  console.log(projects);
  return (
    <div>
      <table border={1}>
        <thead>
          <tr>
            <th>项目</th>
            <th>负责人</th>
          </tr>
        </thead>
        <tbody>
          {
            projects?.map((project)=>{
              return (
                <tr key={project.id}>
                  <td>{project.name}</td>
                  <td>{users?.find(user => project.personId === user.id)?.name || "未知"}</td>
                </tr>
              )
            })
          }
        </tbody>
      </table>
    </div>
  )
}
